<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>computed</title>
</head>
<body>

<div id="app">
  <h2>{{fullName}}</h2>
</div>
<script src="../js/vue.js"></script>
<script>
  const app = new Vue({
    el: '#app',
    data: {
      message: '你好',
      firstName: 'li',
      lastName: 'hao'
    },
    computed: {
      fullName: {
        set: function (newValue) {
          let name = newValue.split(' ')
          this.firstName = name[0]
          this.lastName = name[1]
        },
        get: function () {
          return this.firstName + ' ' + this.lastName
        }
      }
    }
  })
</script>
</body>
</html>
